
package SwingForms;

import LogicaClasesNew.Fabrica;
import LogicaClasesNew.IcontroladorCliente;
import LogicaClasesNew.IcontroladorLineaOrden;
import LogicaClasesNew.IcontroladorOrdenCompra;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;


public class frmInfoCliente extends javax.swing.JInternalFrame {

 
    
    private IcontroladorCliente ICC;
    
    private IcontroladorOrdenCompra ICOC;
    
    private IcontroladorLineaOrden ICLO;
    
    /**
     * Creates new form frmInfoCliente
     */
    public frmInfoCliente() {
        
        //INSTANCIO LA FABRICA
        
        Fabrica fabrica = Fabrica.getInstance();
    
        this.ICC = fabrica.getControladorCliente();
    
        this.ICOC = fabrica.getControladorOrdenCompra();
        
        initComponents();
        CrearModelo2();
        CrearModelo();
        llenartabla();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jtusuarios = new javax.swing.JTable();
        JL_infoUsuarioInfoUsuario = new javax.swing.JLabel();
        JL_InfoUsuarioNickName = new javax.swing.JLabel();
        JTF_InfoUsuarioNickName = new javax.swing.JTextField();
        JL_InfoUsuarioNombre = new javax.swing.JLabel();
        JTF_InfoUsuarioNombre = new javax.swing.JTextField();
        JL_InfoUsuarioApellido = new javax.swing.JLabel();
        JTF_InfoUsuarioApellido = new javax.swing.JTextField();
        JL_InfoUsuarioFechaNacimiento = new javax.swing.JLabel();
        JTF_InfoUsuarioFnacimiento = new javax.swing.JTextField();
        JL_UsuarioMail = new javax.swing.JLabel();
        JTF_InfoUsuarioMail = new javax.swing.JTextField();
        JB_InfoProveedorSalir = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        JCB_InfoClienteOrdenCompra = new javax.swing.JComboBox();
        jScrollPane2 = new javax.swing.JScrollPane();
        JT_InfoClienteInfoOrdenCompra = new javax.swing.JTable();
        JL_InfoOrdenNumero1 = new javax.swing.JLabel();
        JTF_InfoOrdenFecha = new javax.swing.JTextField();
        JL_UsuarioMail1 = new javax.swing.JLabel();
        JTF_InfoOrdenTotal = new javax.swing.JTextField();
        JL_InfoClienteFoto = new javax.swing.JLabel();

        setTitle("Informacion de Cliente");

        jtusuarios.setForeground(new java.awt.Color(51, 0, 51));
        jtusuarios.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Nickname", "nombre"
            }
        ));
        jtusuarios.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtusuariosMouseClicked(evt);
            }
        });
        jtusuarios.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentMoved(java.awt.event.ComponentEvent evt) {
                jtusuariosComponentMoved(evt);
            }
        });
        jScrollPane1.setViewportView(jtusuarios);

        JL_infoUsuarioInfoUsuario.setFont(new java.awt.Font("Trebuchet MS", 1, 14)); // NOI18N
        JL_infoUsuarioInfoUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/InfooCliente.png"))); // NOI18N

        JL_InfoUsuarioNickName.setText("* NickName:");

        JTF_InfoUsuarioNickName.setEditable(false);
        JTF_InfoUsuarioNickName.setForeground(new java.awt.Color(153, 0, 153));
        JTF_InfoUsuarioNickName.setToolTipText("Ingrese un Alias que lo Identificar{a");
        JTF_InfoUsuarioNickName.setCaretColor(new java.awt.Color(153, 0, 153));
        JTF_InfoUsuarioNickName.setDisabledTextColor(new java.awt.Color(153, 0, 153));

        JL_InfoUsuarioNombre.setText("* Nombre:");

        JTF_InfoUsuarioNombre.setEditable(false);
        JTF_InfoUsuarioNombre.setForeground(new java.awt.Color(153, 0, 153));
        JTF_InfoUsuarioNombre.setToolTipText("Ingrese su Nombre");
        JTF_InfoUsuarioNombre.setDisabledTextColor(new java.awt.Color(153, 0, 153));

        JL_InfoUsuarioApellido.setText("* Apellido:");

        JTF_InfoUsuarioApellido.setEditable(false);
        JTF_InfoUsuarioApellido.setForeground(new java.awt.Color(153, 0, 153));
        JTF_InfoUsuarioApellido.setToolTipText("Ingrese su apellido");
        JTF_InfoUsuarioApellido.setDisabledTextColor(new java.awt.Color(153, 0, 153));

        JL_InfoUsuarioFechaNacimiento.setText("*Fecha de Nacimiento:");

        JTF_InfoUsuarioFnacimiento.setEditable(false);
        JTF_InfoUsuarioFnacimiento.setForeground(new java.awt.Color(153, 0, 153));
        JTF_InfoUsuarioFnacimiento.setDisabledTextColor(new java.awt.Color(153, 0, 153));

        JL_UsuarioMail.setText("*Correo  electronico:");

        JTF_InfoUsuarioMail.setEditable(false);
        JTF_InfoUsuarioMail.setForeground(new java.awt.Color(153, 0, 153));
        JTF_InfoUsuarioMail.setDisabledTextColor(new java.awt.Color(153, 0, 153));

        JB_InfoProveedorSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Cerrar.png"))); // NOI18N
        JB_InfoProveedorSalir.setToolTipText("Cierra Ventana");
        JB_InfoProveedorSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_InfoProveedorSalirActionPerformed(evt);
            }
        });

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/SelecCliente.png"))); // NOI18N

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/InfoOrdCompra.png"))); // NOI18N

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/SeleccioneOrdCompra.png"))); // NOI18N

        JCB_InfoClienteOrdenCompra.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione Orden de Compra" }));
        JCB_InfoClienteOrdenCompra.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                JCB_InfoClienteOrdenCompraMouseClicked(evt);
            }
        });
        JCB_InfoClienteOrdenCompra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JCB_InfoClienteOrdenCompraActionPerformed(evt);
            }
        });
        JCB_InfoClienteOrdenCompra.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                JCB_InfoClienteOrdenCompraKeyPressed(evt);
            }
        });

        JT_InfoClienteInfoOrdenCompra.setForeground(new java.awt.Color(51, 0, 51));
        JT_InfoClienteInfoOrdenCompra.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Nombre", "Precio Unitario", "Cantidad", "Subtotal"
            }
        ));
        JT_InfoClienteInfoOrdenCompra.setEnabled(false);
        jScrollPane2.setViewportView(JT_InfoClienteInfoOrdenCompra);

        JL_InfoOrdenNumero1.setText("Fecha");

        JTF_InfoOrdenFecha.setEditable(false);
        JTF_InfoOrdenFecha.setForeground(new java.awt.Color(153, 0, 153));
        JTF_InfoOrdenFecha.setToolTipText("Ingrese un Alias que lo Identificar{a");
        JTF_InfoOrdenFecha.setCaretColor(new java.awt.Color(153, 0, 153));
        JTF_InfoOrdenFecha.setDisabledTextColor(new java.awt.Color(153, 0, 153));

        JL_UsuarioMail1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        JL_UsuarioMail1.setText("TOTAL:");

        JTF_InfoOrdenTotal.setEditable(false);
        JTF_InfoOrdenTotal.setForeground(new java.awt.Color(153, 0, 153));
        JTF_InfoOrdenTotal.setDisabledTextColor(new java.awt.Color(153, 0, 153));

        JL_InfoClienteFoto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        JL_InfoClienteFoto.setVerifyInputWhenFocusTarget(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(24, 24, 24)
                                .addComponent(JL_InfoUsuarioFechaNacimiento))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(74, 74, 74)
                                .addComponent(JL_InfoUsuarioNickName))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(83, 83, 83)
                                .addComponent(JL_InfoUsuarioNombre))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(JL_UsuarioMail))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(83, 83, 83)
                                .addComponent(JL_InfoUsuarioApellido)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(JTF_InfoUsuarioMail, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JTF_InfoUsuarioNickName, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JTF_InfoUsuarioNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JTF_InfoUsuarioApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JTF_InfoUsuarioFnacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 117, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(JL_infoUsuarioInfoUsuario))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(21, 21, 21)
                                        .addComponent(jLabel1))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(57, 57, 57)
                                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(18, 18, 18)
                                .addComponent(JL_InfoClienteFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(JCB_InfoClienteOrdenCompra, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(16, 16, 16))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(JB_InfoProveedorSalir)
                            .addGap(54, 54, 54))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(JL_InfoOrdenNumero1)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(JL_UsuarioMail1))
                            .addGap(41, 41, 41)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(134, 134, 134)
                                .addComponent(JTF_InfoOrdenTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(131, 131, 131)
                                .addComponent(JTF_InfoOrdenFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(129, 129, 129))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel2)
                                .addComponent(JCB_InfoClienteOrdenCompra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(JTF_InfoOrdenFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JL_InfoOrdenNumero1))
                        .addGap(37, 37, 37)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(76, 76, 76)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(67, 67, 67)
                                .addComponent(JL_InfoClienteFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                        .addComponent(JL_infoUsuarioInfoUsuario)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(JL_InfoUsuarioNickName))
                            .addComponent(JTF_InfoUsuarioNickName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(JL_InfoUsuarioNombre))
                            .addComponent(JTF_InfoUsuarioNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(JL_InfoUsuarioApellido))
                            .addComponent(JTF_InfoUsuarioApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(8, 8, 8)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 55, Short.MAX_VALUE)
                                .addComponent(JB_InfoProveedorSalir)
                                .addGap(20, 20, 20))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(7, 7, 7)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(3, 3, 3)
                                        .addComponent(JL_InfoUsuarioFechaNacimiento))
                                    .addComponent(JTF_InfoUsuarioFnacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(3, 3, 3)
                                        .addComponent(JL_UsuarioMail))
                                    .addComponent(JTF_InfoUsuarioMail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(JTF_InfoOrdenTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JL_UsuarioMail1))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jtusuariosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtusuariosMouseClicked
        // TODO add your handling code here:
        try {
            int row= jtusuarios.getSelectedRow();
            String nick=(jtusuarios.getModel().getValueAt(row, 0).toString());

            JTF_InfoUsuarioNickName.setText(ICC.findCliente(nick).getNickname());
            JTF_InfoUsuarioNombre.setText(ICC.findCliente(nick).getNombre());
            JTF_InfoUsuarioApellido.setText(ICC.findCliente(nick).getApellido());
            JTF_InfoUsuarioMail.setText(ICC.findCliente(nick).getMail());
            JTF_InfoUsuarioFnacimiento.setText(ICC.findCliente(nick).getFechNacim());
            
            //cargo el comboBox
            iniciarComboBoxOrden(ICC.findCliente(nick).getNickname());
            
            if (ICC.findCliente(nick).getFoto() != null){
                
                ImageIcon foto = new ImageIcon( ICC.findCliente(nick).getFoto() );
                Image img = foto.getImage(); //convertimos icon en una imagen
                Image otraimg = img.getScaledInstance(135, 135, java.awt.Image.SCALE_SMOOTH ); 
                ImageIcon otroicon = new ImageIcon( otraimg );

                JL_InfoClienteFoto.setIcon(otroicon);
            }else{
                JL_InfoClienteFoto.setIcon(null);
            }//FIN de if

            
        } catch (Exception e) {
            getToolkit().beep();
            JOptionPane.showMessageDialog(this, "ERROR\n" + e, "Error", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_jtusuariosMouseClicked

    private void jtusuariosComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jtusuariosComponentMoved
        // TODO add your handling code here:
    }//GEN-LAST:event_jtusuariosComponentMoved

    //CERRAR
    private void JB_InfoProveedorSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_InfoProveedorSalirActionPerformed
        //Oculta formulario
        this.setVisible (false);
    }//GEN-LAST:event_JB_InfoProveedorSalirActionPerformed

    private void JCB_InfoClienteOrdenCompraKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_JCB_InfoClienteOrdenCompraKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_JCB_InfoClienteOrdenCompraKeyPressed

    //CLIQUEO la opcion
    private void JCB_InfoClienteOrdenCompraMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JCB_InfoClienteOrdenCompraMouseClicked
        
        //TRAIGO el numero de orden
        int numero = Integer.parseInt(JCB_InfoClienteOrdenCompra.getSelectedItem().toString());
   
        llenartablaOrden(numero); // SE LE PASA EL NUMERO DE ORDEN COMPRA
        
        
    }//GEN-LAST:event_JCB_InfoClienteOrdenCompraMouseClicked

    private void JCB_InfoClienteOrdenCompraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JCB_InfoClienteOrdenCompraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JCB_InfoClienteOrdenCompraActionPerformed

    //METODO iniciar ComboBox de Proveedor  
private void iniciarComboBoxOrden(String Nickname) {

    if( JCB_InfoClienteOrdenCompra.getItemCount() == 0){          
        try {
            for(int i = 0; i < ICOC.findOrdenCompraEntities().size(); i++) {
                
                if ( ((Nickname).equals(ICOC.findOrdenCompraEntities().get(i).getCliente().getNickname())) && !ICOC.findOrdenCompraEntities().get(i).isBajaLogica()){
                 
                String numero = Integer.toString( ICOC.findOrdenCompraEntities().get(i).getNumero() );
                JCB_InfoClienteOrdenCompra.addItem(numero);
                }
                
                }
        }
        catch (Exception e){
            getToolkit().beep();
            JOptionPane.showMessageDialog(this, e.getMessage());
        }
    }  
     else{
            JCB_InfoClienteOrdenCompra.removeAllItems();            
            JT_InfoClienteInfoOrdenCompra.removeAll();
            
            try {
            
                for(int i = 0; i < ICOC.findOrdenCompraEntities().size(); i++) {
                
                if ( ((Nickname).equals(ICOC.findOrdenCompraEntities().get(i).getCliente().getNickname())) && !ICOC.findOrdenCompraEntities().get(i).isBajaLogica()){
                 
                String numero = Integer.toString( ICOC.findOrdenCompraEntities().get(i).getNumero() );
                JCB_InfoClienteOrdenCompra.addItem(numero);
                }
                
                }
        }
        catch (Exception e){
            getToolkit().beep();
            JOptionPane.showMessageDialog(this, e.getMessage());
        }
     }   

}



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JB_InfoProveedorSalir;
    private javax.swing.JComboBox JCB_InfoClienteOrdenCompra;
    private javax.swing.JLabel JL_InfoClienteFoto;
    private javax.swing.JLabel JL_InfoOrdenNumero1;
    private javax.swing.JLabel JL_InfoUsuarioApellido;
    private javax.swing.JLabel JL_InfoUsuarioFechaNacimiento;
    private javax.swing.JLabel JL_InfoUsuarioNickName;
    private javax.swing.JLabel JL_InfoUsuarioNombre;
    private javax.swing.JLabel JL_UsuarioMail;
    private javax.swing.JLabel JL_UsuarioMail1;
    private javax.swing.JLabel JL_infoUsuarioInfoUsuario;
    private javax.swing.JTextField JTF_InfoOrdenFecha;
    private javax.swing.JTextField JTF_InfoOrdenTotal;
    private javax.swing.JTextField JTF_InfoUsuarioApellido;
    private javax.swing.JTextField JTF_InfoUsuarioFnacimiento;
    private javax.swing.JTextField JTF_InfoUsuarioMail;
    private javax.swing.JTextField JTF_InfoUsuarioNickName;
    private javax.swing.JTextField JTF_InfoUsuarioNombre;
    private javax.swing.JTable JT_InfoClienteInfoOrdenCompra;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jtusuarios;
    // End of variables declaration//GEN-END:variables
    
    public static DefaultTableModel modelo;
    
    private void CrearModelo(){
         try {
             modelo = (new DefaultTableModel(
                null, new String [] {
                "Nickname","Correo Electronico"}){
                Class[] types = new Class [] {
                java.lang.String.class,
                java.lang.String.class
    };
                boolean[] canEdit = new boolean [] {
                false,false,false,false
                };
                @Override
                public Class getColumnClass(int columnIndex) {
                   return types [columnIndex];
                }
                @Override
                public boolean isCellEditable(int rowIndex, int colIndex){
                   return canEdit [colIndex];
                }
            });
          jtusuarios.setModel(modelo);
         } catch (Exception e) {
             getToolkit().beep();
             JOptionPane.showMessageDialog(null,e.toString()+"error2");
            }    
     }

    public static DefaultTableModel modelo2;
    
    private void CrearModelo2(){
         try {
             modelo2 = (new DefaultTableModel(
                null, new String [] {
                "Nombre","Precio Unitario","Cantidad","Subtotal"}){
                Class[] types = new Class [] {
                java.lang.String.class,
                java.lang.String.class,
                java.lang.String.class,
                java.lang.String.class
    };
                boolean[] canEdit = new boolean [] {
                false,false,false,false
                };
                @Override
                public Class getColumnClass(int columnIndex) {
                   return types [columnIndex];
                }
                @Override
                public boolean isCellEditable(int rowIndex, int colIndex){
                   return canEdit [colIndex];
                }
            });
          JT_InfoClienteInfoOrdenCompra.setModel(modelo2);
         } catch (Exception e) {
             getToolkit().beep();
             JOptionPane.showMessageDialog(null,e.toString()+"error2");
            }    
     }
    
    private void llenartabla (){
        
         try {
            Object A[] = null;
            for (int i = 0; i < ICC.findClienteEntities().size(); i++) {
                modelo.addRow(A);
                modelo.setValueAt(ICC.findClienteEntities().get(i).getNickname(), i, 0);
                modelo.setValueAt(ICC.findClienteEntities().get(i).getMail(), i, 1);                
            }
        }
        catch (Exception e){
            getToolkit().beep();
            JOptionPane.showMessageDialog(this, e.getMessage());
        }
    }
    
    //SE PASA LA ORDEN DE COMPRA POR PARAMETRO 
     private void llenartablaOrden (Integer numero){
        clearJT_InfoClienteInfoOrdenCompra();   
      
        //OrdenCompraJpaController jpaOrdCompr = new OrdenCompraJpaController();
        
        try {
            Object A[] = null;
              //ESTE FOR ESTA MAL SERIA UN WHILE PUESTO Q SOLO TENDREMOS UNA ORDEN SELECCIONADA 
            for (int i = 0; i < ICOC.findOrdenCompraEntities().size(); i++) {
                if (ICOC.findOrdenCompraEntities().get(i).getNumero() == numero){
                    String fecha=String.valueOf(ICOC.findOrdenCompraEntities().get(i).getFechaOrden());
                    String mitotal=String.valueOf(ICOC.findOrdenCompraEntities().get(i).getPrecioTotal());
                    JTF_InfoOrdenFecha.setText(fecha);
                    JTF_InfoOrdenTotal.setText(mitotal);

                        for (int j = 0; j < ICOC.findOrdenCompraEntities().get(i).getLineasOrden().size(); j++){
                                modelo2.addRow(A);
                                modelo2.setValueAt(ICOC.findOrdenCompraEntities().get(i).getLineasOrden().get(j).getP().getNombre(), j, 0);
                                modelo2.setValueAt(ICOC.findOrdenCompraEntities().get(i).getLineasOrden().get(j).getPrecioactual(), j, 1);
                                modelo2.setValueAt(ICOC.findOrdenCompraEntities().get(i).getLineasOrden().get(j).getCantidad(), j, 2);
                                float subtotal= (ICOC.findOrdenCompraEntities().get(i).getLineasOrden().get(j).getPrecioactual()*ICOC.findOrdenCompraEntities().get(i).getLineasOrden().get(j).getCantidad());
                                modelo2.setValueAt((subtotal), j, 3);
                               }
                    }
                    
                }    
            }
        
        catch (Exception e){
           JOptionPane.showMessageDialog(this, e.getMessage());
        }
    }
    
     
     private void clearJT_InfoClienteInfoOrdenCompra(){
        for (int i = 0; i < JT_InfoClienteInfoOrdenCompra.getRowCount(); i++) {
        modelo2.removeRow(i);
        i-=1;
        }

    }
  

 }